/**
 * 
 */
package com.flashdeck.domain;

/**
 * @author Vincentas
 *
 */
public class Feedback {

	private String subject;
	
	private String message;
	
	public Feedback(String subject, String message) {
		this.subject = subject;
		this.message = message;
	}
	
	public Sender send(final ProgressListener progressListener) {
		return new Sender() {
			
			private boolean canceled = false;
			
			{
				new Thread(new Runnable() {
					
					@Override
					public void run() {
						try {
							Thread.sleep(3000);
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
						
						if (!canceled) {
							progressListener.onSuccess();
						}
					}
				}).start();
			}
			
			@Override
			public void cancel() {
				canceled = true;				
			}
		};
	}
	
	public interface ProgressListener {
		
		void onSuccess();
		void onFailure();
		
	}
	
	public interface Sender {
		
		void cancel();
	}
}
